package com.lecosa.flink;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestStr {
    public static void main(String[] args) {
        String input = "SourceRecord{sourcePartition={server=mysql_binlog_source}, sourceOffset={ts_sec=1713952481, file=mysql-bin.000082, pos=1055, snapshot=true}} ConnectRecord{topic='mysql_binlog_source.shufen.student', kafkaPartition=null, key=Struct{id=8}, keySchema=Schema{mysql_binlog_source.shufen.student.Key:STRUCT}, value=Struct{after=Struct{id=8,no=20201720,name=刘楠颖,gender=男},source=Struct{version=1.5.4.Final,connector=mysql,name=mysql_binlog_source,ts_ms=1713952481630,snapshot=true,db=shufen,table=student,server_id=0,file=mysql-bin.000082,pos=1055,row=0},op=r,ts_ms=1713952481630}, valueSchema=Schema{mysql_binlog_source.shufen.student.Envelope:STRUCT}, timestamp=null, headers=ConnectHeaders(headers=)}";

        // 匹配 id 的正则表达式
        Pattern idPattern = Pattern.compile("id=(\\d+)");
        Matcher idMatcher = idPattern.matcher(input);
        if (idMatcher.find()) {
            String id = idMatcher.group(1);
            System.out.println("ID: " + id);
        }

        // 匹配 no 的正则表达式
        Pattern noPattern = Pattern.compile("no=(\\d+)");
        Matcher noMatcher = noPattern.matcher(input);
        if (noMatcher.find()) {
            String no = noMatcher.group(1);
            System.out.println("No: " + no);
        }

        // 匹配 name 的正则表达式
        Pattern namePattern = Pattern.compile("name=([^,]+)");
        Matcher nameMatcher = namePattern.matcher(input);
        if (nameMatcher.find()) {
            String name = nameMatcher.group(1);
            System.out.println("Name: " + name);
        }
    }
}
